﻿<phoneNavigation:PhoneApplicationPage 
    x:Class="BeeHivePhone.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phoneNavigation="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Navigation"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
	xmlns:il="clr-namespace:Microsoft.Expression.Interactivity.Layout;assembly=Microsoft.Expression.Interactions"
	xmlns:im="clr-namespace:Microsoft.Expression.Interactivity.Media;assembly=Microsoft.Expression.Interactions"
	xmlns:ic="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions"
	xmlns:System_Windows_Interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
	xmlns:local="clr-namespace:BeeHivePhone"
	xmlns:System="clr-namespace:System;assembly=mscorlib"
	xmlns:ii="clr-namespace:Microsoft.Expression.Interactivity.Input;assembly=Microsoft.Expression.Interactions"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}">

<Grid x:Name="LayoutRoot">
		<VisualStateManager.VisualStateGroups>
			<VisualStateGroup x:Name="GameStatus">
				<VisualState x:Name="WaitStart">
					<Storyboard RepeatBehavior="Forever">
						<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ClicktoStart" Storyboard.TargetProperty="(UIElement.Visibility)">
							<DiscreteObjectKeyFrame KeyTime="00:00:00.7000000">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Visible</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
							<DiscreteObjectKeyFrame KeyTime="00:00:00.8000000">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Collapsed</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
							<DiscreteObjectKeyFrame KeyTime="00:00:00.9000000">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Collapsed</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
						<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="GameOver" Storyboard.TargetProperty="(UIElement.Visibility)">
							<DiscreteObjectKeyFrame KeyTime="00:00:00">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Collapsed</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
					</Storyboard>
				</VisualState>
				<VisualState x:Name="StartGame">
					<Storyboard>
						<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="ClicktoStart" Storyboard.TargetProperty="(UIElement.Visibility)">
							<DiscreteObjectKeyFrame KeyTime="00:00:00">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Collapsed</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
					</Storyboard>
				</VisualState>
				<VisualState x:Name="ShowGameOver">
					<Storyboard>
						<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="GameOver" Storyboard.TargetProperty="(UIElement.Visibility)">
							<DiscreteObjectKeyFrame KeyTime="00:00:00">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Visible</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
					</Storyboard>
				</VisualState>
			</VisualStateGroup>
			<VisualStateGroup x:Name="Levels">
				<VisualState x:Name="Level1">
					<Storyboard>
						<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="masterHead_bg" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
							<EasingColorKeyFrame KeyTime="00:00:00" Value="#FF2A341A"/>
						</ColorAnimationUsingKeyFrames>

						<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="levelHostControl" Storyboard.TargetProperty="(LevelHostControl.HostFile)">
							<DiscreteObjectKeyFrame KeyTime="00:00:00" Value="Level1.xaml"/>
						</ObjectAnimationUsingKeyFrames>
					</Storyboard>
				</VisualState>
				<VisualState x:Name="Level2">
					<Storyboard>
						<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="masterHead_bg" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
							<EasingColorKeyFrame KeyTime="00:00:00" Value="#FF1A2C31"/>
						</ColorAnimationUsingKeyFrames>

						<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="levelHostControl" Storyboard.TargetProperty="(LevelHostControl.HostFile)">
							<DiscreteObjectKeyFrame KeyTime="00:00:00" Value="Level2.xaml"/>
						</ObjectAnimationUsingKeyFrames>
					</Storyboard>
				</VisualState>
				<VisualState x:Name="Level3">
					<Storyboard>
						<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="masterHead_bg" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
							<EasingColorKeyFrame KeyTime="00:00:00" Value="#FF2B1A31"/>
						</ColorAnimationUsingKeyFrames>

						<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="levelHostControl" Storyboard.TargetProperty="(LevelHostControl.HostFile)">
							<DiscreteObjectKeyFrame KeyTime="00:00:00" Value="Level3.xaml"/>
						</ObjectAnimationUsingKeyFrames>
					</Storyboard>
				</VisualState>
				<VisualState x:Name="GameOverLevel"/>
				
			</VisualStateGroup>
		</VisualStateManager.VisualStateGroups>
		<Canvas x:Name="BeeHive" Height="800" Width="480" HorizontalAlignment="Center" Margin="0" VerticalAlignment="Bottom">
			<System_Windows_Interactivity:Interaction.Behaviors>
				<local:GameEnvironment x:Name="gameEnvironment" GameOverSound="Audio/gameover.mp3" GameOverState="ShowGameOver" NextLevelSound="Audio/start.mp3">
					<System_Windows_Interactivity:Interaction.Triggers>
						<local:CollisionTrigger SourceName="BOTTOM_WALL">
							<System_Windows_Interactivity:InvokeCommandAction CommandName="ResetCommand"/>
						</local:CollisionTrigger>
					</System_Windows_Interactivity:Interaction.Triggers>
				</local:GameEnvironment>
			</System_Windows_Interactivity:Interaction.Behaviors>
			<System_Windows_Interactivity:Interaction.Triggers>
				<System_Windows_Interactivity:EventTrigger EventName="Loaded">
					<ic:GoToStateAction StateName="WaitStart"/>
				</System_Windows_Interactivity:EventTrigger>
				<ii:KeyTrigger Key="NumPad3">
					<ic:GoToStateAction StateName="Level3"/>
				</ii:KeyTrigger>
				<System_Windows_Interactivity:EventTrigger SourceName="gameEnvironment" EventName="GameOver">
					<im:PlaySoundAction Source="Audio/gameover.mp3"/>
				</System_Windows_Interactivity:EventTrigger>
			</System_Windows_Interactivity:Interaction.Triggers>
			<Rectangle x:Name="masterHead_bg" Fill="#FF28311A" Stroke="{x:Null}" Height="57" Canvas.Left="-42" Canvas.Top="-10" Width="522"/>
			<local:LevelHostControl x:Name="levelHostControl" Height="749" Width="480" HostFile="Level1.xaml" Canvas.Left="4" Canvas.Top="51"/>
			<Image x:Name="LEFT_WALL" Height="792" Width="6" Opacity="0.102" Canvas.Left="0" Canvas.Top="0" Source="BeeHive_Images/LEFT_WALL.png">
				<System_Windows_Interactivity:Interaction.Triggers>
					<local:CollisionTrigger>
						<im:PlaySoundAction Source="Audio/wall.mp3"/>
					</local:CollisionTrigger>
				</System_Windows_Interactivity:Interaction.Triggers>
				<System_Windows_Interactivity:Interaction.Behaviors>
					<local:CollisionBehavior/>
				</System_Windows_Interactivity:Interaction.Behaviors>
			</Image>
			<Image x:Name="TOP_WALL" Height="32" Width="480" Opacity="0.102" Canvas.Left="6" Source="BeeHive_Images/TOP_WALL.png" Canvas.Top="12">
				<System_Windows_Interactivity:Interaction.Triggers>
					<local:CollisionTrigger>
						<im:PlaySoundAction Source="Audio/wall.mp3"/>
					</local:CollisionTrigger>
				</System_Windows_Interactivity:Interaction.Triggers>
				<System_Windows_Interactivity:Interaction.Behaviors>
					<local:CollisionBehavior/>
				</System_Windows_Interactivity:Interaction.Behaviors>
			</Image>
			<Image x:Name="RIGHT_WALL" Height="800" Width="9" Opacity="0.102" Canvas.Left="480" Canvas.Top="9" Source="BeeHive_Images/RIGHT_WALL.png">
				<System_Windows_Interactivity:Interaction.Triggers>
					<local:CollisionTrigger>
						<im:PlaySoundAction Source="Audio/wall.mp3"/>
					</local:CollisionTrigger>
				</System_Windows_Interactivity:Interaction.Triggers>
				<System_Windows_Interactivity:Interaction.Behaviors>
					<local:CollisionBehavior/>
				</System_Windows_Interactivity:Interaction.Behaviors>
			</Image>
			<Image x:Name="BOTTOM_WALL" Height="20" Width="485" Canvas.Left="0" Canvas.Top="787" Source="BeeHive_Images/BOTTOM_WALL.png">
				<System_Windows_Interactivity:Interaction.Triggers>
					<local:CollisionTrigger>
						<im:PlaySoundAction Source="Audio/lostLife.mp3"/>
					</local:CollisionTrigger>
				</System_Windows_Interactivity:Interaction.Triggers>
				<System_Windows_Interactivity:Interaction.Behaviors>
					<local:CollisionBehavior/>
				</System_Windows_Interactivity:Interaction.Behaviors>
			</Image>
			<Image x:Name="BALL" Height="40" Width="40" Canvas.Left="229" Canvas.Top="646" Source="BeeHive_Images/BALL.png" Tag="CollideWithAll">
				<System_Windows_Interactivity:Interaction.Behaviors>
					<local:MotionBehavior Direction="-65" Speed="15"/>
					<local:MovableBehavior/>
				</System_Windows_Interactivity:Interaction.Behaviors>
				<System_Windows_Interactivity:Interaction.Triggers>
					<System_Windows_Interactivity:EventTrigger EventName="MouseLeftButtonUp">
						<im:PlaySoundAction Source="Audio/start.mp3"/>
						<ic:GoToStateAction StateName="StartGame"/>
					</System_Windows_Interactivity:EventTrigger>
				</System_Windows_Interactivity:Interaction.Triggers>
			</Image>
			<Image x:Name="PADDLE" Height="29" Width="150" Canvas.Left="171" Canvas.Top="730" Source="BeeHive_Images/PADDLE.png" RenderTransformOrigin="0.5,0.5">
				<System_Windows_Interactivity:Interaction.Behaviors>
					<local:FollowMouseBehavior Margin="15,0" FollowPosition="X" />
					<local:CollisionBehavior/>
					<local:MovableBehavior/>
				</System_Windows_Interactivity:Interaction.Behaviors>
				<System_Windows_Interactivity:Interaction.Triggers>
					<System_Windows_Interactivity:EventTrigger/>
					<local:CollisionTrigger>
						<im:PlaySoundAction Source="Audio/paddle.mp3" Volume="1"/>
					</local:CollisionTrigger>
				</System_Windows_Interactivity:Interaction.Triggers>
			</Image>
			<TextBlock x:Name="ScoreText" Canvas.Left="8" Canvas.Top="29" FontFamily="Arial" FontSize="17" FontWeight="Bold" Foreground="#FFFFFFFF" LineHeight="17" LineStackingStrategy="BlockLineHeight" Text="0" TextWrapping="Wrap" Width="92">
				<System_Windows_Interactivity:Interaction.Behaviors>
					<local:GamePropertyUpdateBehavior PropertyName="Score"/>
				</System_Windows_Interactivity:Interaction.Behaviors>
			</TextBlock>
			<TextBlock x:Name="LivesText" Canvas.Left="387" Canvas.Top="29" FontFamily="Arial" FontSize="18" FontWeight="Bold" Foreground="#FFFFFFFF" LineHeight="18" LineStackingStrategy="BlockLineHeight" Text="4" TextWrapping="Wrap" Width="60">
				<System_Windows_Interactivity:Interaction.Triggers>
					<local:CollisionTrigger SourceName="BOTTOM_WALL">
						<local:ModifyGamePropertyAction IncrementValue="-1" PropertyName="Lives"/>
					</local:CollisionTrigger>
				</System_Windows_Interactivity:Interaction.Triggers>
				<System_Windows_Interactivity:Interaction.Behaviors>
					<local:GamePropertyUpdateBehavior PropertyName="Lives"/>
				</System_Windows_Interactivity:Interaction.Behaviors>
			</TextBlock>
			<Image x:Name="ClicktoStart" Height="12" Width="290" Source="BeeHive_Images/ClicktoStart.PNG" Stretch="Fill" IsHitTestVisible="False" Canvas.Top="771" Canvas.Left="99"/>
			<Image x:Name="GameOver" Height="54" Width="388" Source="BeeHive_Images/GameOver.PNG" Stretch="Fill" Canvas.Left="201" Canvas.Top="250" Visibility="Collapsed"/>
			<TextBlock x:Name="LastScoreText" Canvas.Left="130" Canvas.Top="29" FontFamily="Arial" FontSize="17" FontWeight="Bold" Foreground="#FFFFFFFF" LineHeight="17" LineStackingStrategy="BlockLineHeight" Text="0" TextWrapping="Wrap" Opacity="0.6" Width="83" Height="17">
				<System_Windows_Interactivity:Interaction.Behaviors>
					<local:GamePropertyUpdateBehavior PropertyName="LastScore"/>
				</System_Windows_Interactivity:Interaction.Behaviors>
			</TextBlock>
			<TextBlock x:Name="HiScoreText" FontFamily="Arial" FontSize="17" FontWeight="Bold" Foreground="#FFFFFFFF" LineHeight="17" LineStackingStrategy="BlockLineHeight" TextWrapping="Wrap" Canvas.Left="227" Canvas.Top="29" Opacity="0.6" Text="0000" Width="143" Height="15">
				<System_Windows_Interactivity:Interaction.Behaviors>
					<local:GamePropertyUpdateBehavior PropertyName="HighScore"/>
				</System_Windows_Interactivity:Interaction.Behaviors>
			</TextBlock>
			<Image Height="12" Width="85" Source="BeeHive_Images/last.PNG" Stretch="Fill" Opacity="0.4" Canvas.Top="12" Canvas.Left="128"/>
			<Image Height="12" Width="143" Source="BeeHive_Images/hiscore.png" Stretch="Fill" Opacity="0.4" Canvas.Top="12" Canvas.Left="227"/>
			<Image x:Name="lives" Height="12" Width="88" Opacity="0.4" Canvas.Left="385" Canvas.Top="12" Source="BeeHive_Images/lives.png"/>
			<Image x:Name="score" Height="12" Width="106" Opacity="0.6" Canvas.Left="8" Canvas.Top="12" Source="BeeHive_Images/score.png"/>
		</Canvas>
	</Grid>
    
</phoneNavigation:PhoneApplicationPage>